<!DOCTYPE html>
<html>
 <head> 
  <meta charset="utf-8" /> 
  <title>全民K歌歌曲下载</title> 
  <link href="favicon.ico" mce_href="favicon.ico" rel="bookmark" type="image/x-icon" /> 
  <link href="favicon.ico" mce_href="favicon.ico" rel="icon" type="image/x-icon" /> 
  <link href="favicon.ico" mce_href="favicon.ico" rel="shortcut icon" type="image/x-icon" /> 
  <script src="./jquery.min.js?=3.4.1"></script> 
  <script src="./jsUrlHelper.js"></script> 
  <script>
	var num=0;
	function MusicJsonCallback (data) {
		for(i=0;i<data.data.ugclist.length; i++){
			var url ="https://node.kg.qq.com/cgi/fcgi-bin/fcg_get_play_url?shareid=" + data.data.ugclist[i].shareid;
			var p = document.createElement('p');//创建p节点
			p.innerHTML = (num+1)+": "+data.data.ugclist[i].title;//p节点显示的文字
			var audio = document.createElement('audio'); //生成一个audio元素 
			audio.controls = true; //这样控件才能显示出来 
			audio.src = url; //音乐的路径 
			audio.preload = "none";
			document.body.appendChild(p); //把p添加到页面中
			document.body.appendChild(audio); //把audio添加到页面中
			
			num++;
		}
    }
					
	var more_flag=1;
	var index=1;
	var fun = function() {
		if (more_flag==1) {
			var src = "https://node.kg.qq.com/cgi/fcgi-bin/kg_ugc_get_homepage?type=get_uinfo&start="+index+"&num=8&share_uid="+userId;
			$.ajax({
						type: "GET",
						url: src,
						dataType: "jsonp",  //指定服务器返回的数据类型
                        jsonpCallback: "MusicJsonCallback",  //指定回调函数名称
						beforeSend: function(request) {
							request.setRequestHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36");
						}
					}).done(function(data) {
						more_flag=data.data.has_more;
						index++;
						fun();
					}).fail(function() {
						console.log("error");
					})
		} else {
			console.log(num);
		}
	}
	
	var userId;
	var myfunction = function(){
		urlUid=document.getElementById("homePage").value;
		userId=jsUrlHelper.getUrlParam(urlUid,"uid");
		fun();
	}
	
	document.onkeydown = function (e) {
		var theEvent = window.event || e;
		var code = theEvent.keyCode || theEvent.which;
		if (code == 13) {
			$("#btn").click();
		}
	}
</script> 
 </head> 
 <body background="http://www.w3school.com.cn/i/eg_bg_06.gif">
   用户主页： 
  <input type="text" id="homePage" placeholder="输入网址" autofocus="autofocus" /> 
  <input type="button" id="btn" value="确定" onclick="myfunction()" />  
 </body>
</html>